package com.qumoyugo.springframework.aop.aspectj;

import com.qumoyugo.springframework.aop.AspectJExpressionPointCut;
import com.qumoyugo.springframework.aop.PointCut;
import com.qumoyugo.springframework.aop.PointCutAdvisor;
import org.aopalliance.aop.Advice;

/**
 * @author Cedric
 * @date 2021/11/30 15:26
 * @description 切面拦截包装类
 */
public class AspectJExpressionPointCutAdvisor implements PointCutAdvisor {
    // 切面
    private AspectJExpressionPointCut pointCut;
    // 具体的拦截方法
    private Advice advice;
    // 拦截表达式
    private String expression;

    public void setExpression(String expression) {
        this.expression = expression;
    }

    @Override
    public PointCut getPointCut() {
        if (null == pointCut) {
            pointCut = new AspectJExpressionPointCut(expression);
        }
        return pointCut;
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    public void setAdvice(Advice advice) {
        this.advice = advice;
    }
}
